package cn.com.thingo.shyintelligent.presenter;

import com.videogo.exception.BaseException;
import com.videogo.openapi.EZOpenSDK;
import com.videogo.openapi.bean.EZAccessToken;
import com.videogo.openapi.bean.EZDeviceInfo;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import cn.com.thingo.shyintelligent.base.RxPresenter;
import cn.com.thingo.shyintelligent.base.contract.EzCameraContract;
import cn.com.thingo.shyintelligent.model.DataManager;
import cn.com.thingo.shyintelligent.model.bean.EzStatementBean;
import cn.com.thingo.shyintelligent.model.db.UserInfo;
import cn.com.thingo.shyintelligent.model.http.api.EzApis;
import cn.com.thingo.shyintelligent.util.EzHttpUtils;
import cn.com.thingo.shyintelligent.util.RxUtil;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class EzCameraPresenter extends RxPresenter<EzCameraContract.View> implements EzCameraContract.Presenter {
    private DataManager dataManager;
    private UserInfo mUserInfo;
    private EzApis mEzApis;
    @Inject
    public EzCameraPresenter(DataManager dataManager) {
        this.dataManager = dataManager;
        mUserInfo = UserInfo.getInstance();
        mEzApis = EzHttpUtils.getInstance().getEzApis();
    }



    @Override
    public void DelEzDevicePermission(String deviceSerial) {
        addSubscribe(mEzApis.postDelStatement(mUserInfo.getAccessToken(),mUserInfo.getAccountId(),deviceSerial).compose(RxUtil.<EzStatementBean>rxSchedulerHelper()).subscribe(new Consumer<EzStatementBean>() {
            @Override
            public void accept(EzStatementBean ezStatementBean) throws Exception {
                mView.viewDelEzDevicePermissionResult(ezStatementBean);
            }
        }));
    }


}
